package com.isoftstone.mapper;

import com.isoftstone.pojo.Occupancy;
import com.isoftstone.pojo.dto.OccupancyQueryDTO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.util.List;

/**
 * @Description:
 * @Author :W.
 * @Date:2025/9/15 15:20
 */
@Mapper
public interface OccupancyMapper {
    List<Occupancy> queryByConditions(OccupancyQueryDTO queryDTO);

    // 根据学生学号查询当前入住记录(在住状态)
    Occupancy findCurrentByStudentNumber(@Param("studentNumber") String studentNumber);

    // 新增入住记录
    int addOccupancy(Occupancy occupancy);

    // 更新入住记录(用于调换宿舍)
    int updateOccupancy(Occupancy occupancy);

    // 退宿处理(单个)
    int checkOut(@Param("occupancyId") Integer occupancyId);

    // 批量退宿
    int batchCheckOut(@Param("ids") List<Integer> ids);

    // 根据宿舍ID查询在住人数
    int countByDormitoryId(@Param("dormitoryId") Integer dormitoryId);

    /**
     * 根据入住记录ID查询
     */
    Occupancy findById(@Param("occupancyId") Integer occupancyId);

    Integer countByConditions(OccupancyQueryDTO queryDTO);
    // 检查是否存在特定状态的记录
    int countByIdsAndStatus(@Param("ids") List<Integer> ids, @Param("status") int status);
    int deleteByIds(@Param("ids") List<Integer> ids);
}
